<template>
    <div class="PerformanceQuery">
        <el-card class="box-card">
            <el-input v-model="phoneNumber" placeholder="根据手机号查询"></el-input>
            <el-button type="primary" class="mb10" size="large" @click="queryInfo">查询</el-button>

            <el-table :data="tableData" style="width: 100%" border stripe>
                <el-table-column :index="indexmethod" type="index" label="" width="90" align="center"> </el-table-column>
                <el-table-column prop="person" label="个人总业绩" align="center"></el-table-column>
                <el-table-column prop="team" label="团队总业绩" align="center"></el-table-column>
                <el-table-column prop="sameMonth" label="当月个人业绩" align="center" width="132"></el-table-column>
                <el-table-column prop="sameMonthTeam" label="当月团队业绩" align="center" width="132"></el-table-column>
                <el-table-column prop="lastMonth" label="上月个人业绩" align="center" width="129"></el-table-column>
                <el-table-column prop="lastMonthTeam" label="上月团队业绩" align="center" width="131"></el-table-column>
                <el-table-column prop="teamCount" :label="'团队总人数:     ' + obj.teamCount + '   人'" align="center" ></el-table-column>
                <el-table-column prop="managerAmount" :label="'晋升区域经理业绩:  ' + obj.managerAmount +  ' 元'" align="center"></el-table-column>
                <el-table-column prop="chiefCount" :label="'晋升区域总监礼包数:' + obj.chiefCount +  ' 个'" align="center"></el-table-column>
                <el-table-column prop="dianzhuMoney" :label="'晋升店主业绩  :  '+ obj.dianzhuMoney +' 元'" align="center"></el-table-column>
            </el-table>
        </el-card>
    </div>
</template>

<script>
import { getAchievementList } from '@/api/member.js'
const textMap = ['Count1', 'Count2', 'Count3', 'Count4', 'Count5', 'Count6', 'Count7', 'DanpinAmount', 'GoodsAmount']

export default {
  name: 'PerformanceQuery',
  data () {
    return {
      phoneNumber: '13957158598',
      tableData: [],
      obj: {
        chiefCount: 0,
        dianzhuMoney:0,
        managerAmount: 0,
        teamCount: 0
      }
    }
  },
  created () {

  },
  mounted () {

  },
  methods: {
    indexmethod (index) {
      return ['69礼包数量', '98礼包数量', '298礼包数量',
        '490礼包数量', '4900礼包数量', '9800礼包数量',
        '49000礼包数量', '复销', '单品'][index]
    },
    async queryInfo () {
      const { Data } = await getAchievementList({
        mobile: 13957158598
      })
      console.log(Data)
      this.obj.chiefCount = Data.chiefCount
      this.obj.dianzhuMoney = Data.dianzhuMoney
      this.obj.managerAmount = Data.managerAmount
      this.obj.teamCount = Data.teamCount
      // const arr = [{ ...Data }]
      const demoArr = []
      const list = Data.list || []
      const length = textMap.length
      for (let index = 0; index < length; index++) {
        demoArr.push({
          person: list[0][textMap[index]],
          team: list[1][textMap[index]],
          sameMonth: list[2][textMap[index]],
          sameMonthTeam: list[3][textMap[index]],
          lastMonth: list[4][textMap[index]],
          lastMonthTeam: list[5][textMap[index]]
        })
      }

      this.tableData = demoArr

      console.log('momo', demoArr)

      // console.log(arr)
    }
  }
}
</script>

<style scoped>
.el-input {
    width: 200px;
    margin-right: 20px;
}
.mb10 {
    margin-bottom: 10px;
}
</style>
